package Year22_Month02.day0223;

import java.util.Scanner;

public class Main {
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char[] arr = s.toCharArray();//转换为字符串来做
        int max = 0;//用来记录最长字符串
        int left = 0;//用来记录最长字符串的左边值
        int right = 0;//用来记录最长字符串的右边值
        int time = 0;//用来记录临时变量
        for (int i = 0; i < arr.length; i++) {
            while(i < arr.length && arr[i] >= '0' && arr[i] <= '9'){
                time++;
                i++;
            }
            if(time > max){
                max = time;
                left = i - time;
                right = i;
            }
            time = 0;
        }
        System.out.println(s.substring(left,right));
    }

    public static int MoreThanHalfNum_Solution(int [] array) {
        if(array.length == 1){
            return array[0];
        }
        int[] arr = new int[10];
        for(int i = 0;i < array.length;i++){
            arr[array[i]]++;
        }
        for(int i = 0;i < arr.length;i++){
            if(arr[i] > array.length / 2){
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] arr = {3,3,3,3,2,2,2};
        System.out.println(MoreThanHalfNum_Solution(arr));
    }
}
